import { inject, injectable } from "inversify";
import { Uri, CancellationToken, WorkspaceEdit, CancellationTokenSource } from "vscode";
import { IApplicationShell, ICommandManager, IDocumentManager } from "../common/application/types";
import { Commands } from "../common/constants";
import { IEQExecutionFactory, IProcessServiceFactory } from "../common/process/types";
import { IConfigurationService, IDisposableRegistry, IEditorUtils, IExtensions, IPersistentStateFactory } from "../common/types";
import { Deferred } from "../common/utils/async";
import { IServiceContainer } from "../ioc/types";
import { ISortImportsEditingProvider } from "./types";

@injectable()
export class SortImportsEditingProvider implements ISortImportsEditingProvider {

  private readonly isortPromises = new Map<
    string,
    { deferred: Deferred<WorkspaceEdit | undefined>; tokenSource: CancellationTokenSource }
  >();

  private readonly processServiceFactory: IProcessServiceFactory;

  private readonly pythonExecutionFactory: IEQExecutionFactory;

  private readonly shell: IApplicationShell;

  private readonly persistentStateFactory: IPersistentStateFactory;

  private readonly documentManager: IDocumentManager;

  private readonly configurationService: IConfigurationService;

  private readonly editorUtils: IEditorUtils;

  private readonly extensions: IExtensions;

  public constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer) {
    this.shell = serviceContainer.get<IApplicationShell>(IApplicationShell);
    this.documentManager = serviceContainer.get<IDocumentManager>(IDocumentManager);
    this.configurationService = serviceContainer.get<IConfigurationService>(IConfigurationService);
    this.pythonExecutionFactory = serviceContainer.get<IEQExecutionFactory>(IEQExecutionFactory);
    this.processServiceFactory = serviceContainer.get<IProcessServiceFactory>(IProcessServiceFactory);
    this.editorUtils = serviceContainer.get<IEditorUtils>(IEditorUtils);
    this.persistentStateFactory = serviceContainer.get<IPersistentStateFactory>(IPersistentStateFactory);
    this.extensions = serviceContainer.get<IExtensions>(IExtensions);
  }
  provideDocumentSortImportsEdits(uri: Uri, token?: CancellationToken): Promise<WorkspaceEdit | undefined> {
    throw new Error("97Method not implemented.");
  }
  sortImports(uri?: Uri): Promise<void> {
    throw new Error("98Method not implemented.");
  }
  public registerCommands(): void {
    const cmdManager = this.serviceContainer.get<ICommandManager>(ICommandManager);
    const disposable = cmdManager.registerCommand(Commands.Sort_Imports, this.sortImports, this);
    this.serviceContainer.get<IDisposableRegistry>(IDisposableRegistry).push(disposable);
}
}